package cn.itcast.cd.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import sun.org.mozilla.javascript.internal.ContextAction;
import cn.itcast.cd.domain.Student;
import cn.itcast.cd.service.IStudentService;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class StudentAction extends ActionSupport {

	private IStudentService studentService;

	public void setStudentService(IStudentService studentService) {
		this.studentService = studentService;
		
		//我晕要加包才行.
	}
	
	public String input(){
		
		return INPUT;
	}
	
	public String save(){
		HttpServletRequest request = ServletActionContext.getRequest();
		String name = request.getParameter("name");
		String salary = request.getParameter("salary");
		Student s = new Student();
		s.setName(name);
		s.setSalary(Double.parseDouble(salary));
		
		studentService.save(s);
		return SUCCESS;
	}
}
